package org.loong.crypto.service.core.provider;

import org.loong.crypto.common.exception.CryptoException;
import org.loong.crypto.core.algorithm.CipherAlgorithm;
import org.loong.crypto.core.params.CipherParameters;

/**
 * Cipher Decrypter.
 */
public interface Decrypter extends CipherProvider {

    /**
     * Initialise the decrypter for decrypt.
     * 
     * @param parameters the cipher parameters.
     */
    default void init(CipherParameters parameters) {
        
    }
    
    /**
     * Decrypt data.
     * 
     * @param algorithm the algorithm
     * @param cipherText the cipher text to decrypt
     * @return the plain text
     * @throws CryptoException the {@link CryptoException}
     */
    byte[] decrypt(final CipherAlgorithm algorithm, final byte[] cipherText) throws CryptoException;
}
